<?php 
$base = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$f_core = $base . "core" . DIRECTORY_SEPARATOR;
$f_template = $base . "template" . DIRECTORY_SEPARATOR;
 
$extension_file = ".php";

$appTitle = "Mi Raiz (Arbol Genealogico)";
$appUrl = "http://apps.facebook.com/miraizfamiliar/";

require $f_core . 'gfacebook.php'; //cargando 
require $f_core . 'facebook.php'; //cargando
require $f_core . 'functions.php'; //cargando
 
$appId = '216293368477312';
$appSecret = '9ad856b6db092220e20aecd2b3dcb291';
$invitarMessage = "Te invito a ser parte de Mi Raiz y crear tu propia arbol genealogico";
 
 
 // Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => $appId,
  'secret' => $appSecret,
));

// Get User ID
$user = $facebook->getUser();

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
} // validacion para saber si el usuario esta logueado


// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl(array(  
    'scope' => 'email,user_birthday,publish_stream,user_photos,user_online_presence,user_relationships,offline_access','redirect_uri'=>'http://apps.facebook.com/miraizfamiliar/'  
)); 
}

$json_main = json_decode(
'{"bottons":[	{"name":"Inicio","target":"_top","sk":"home"},
				{"name":"Mi Arbol","target":"_top","sk":"miarbol"},
				{"name":"Invitar Amigos","target":"_top","sk":"invitar"},
				{"name":"Amigos Que ya lo Utilizan","target":"_top","sk":"amigos"},
				{"name":"Donar","target":"_top","sk":"donar"},
				{"name":"Cancelar","target":"_top","sk":"cancelar"}]}');

$page = ( isset( $_GET['sk'] ) && !empty( $_GET['sk'] ) ) ? $_GET['sk'] : "home";

if ($user)	//voy aclarar las variables solo si la sesion esta activa
	{
	$userID = $_SESSION['fb_'.$appId. '_user_id'];
	$access_token = $_SESSION['fb_'.$appId. '_access_token'];
	}
?>